/**
 * Created by shidaiapp on 2017/9/29.
 */


const validatePassCheck = (rule, value, callback) => {
  if (value === '') {
    callback(new Error('请再次输入密码'));
  } else if (value !== params.user.password) {
    callback(new Error('两次输入密码不一致!'));
  } else {
    callback();
  }
};
const tableCloum = function (self) {
  return {
    title: '综合操作',
    key: 'action',
    width: 200,
    render: (h, params) => {

      return (
        <div>
          < i-button type="primary" size="small"  style="margin-right:10px" onClick={() => {self.editItem(params.index)}}>编辑</i-button>
          < i-button type="error" size="small"  style="margin-right:10px" onClick={() => {self.deleteAction(params.index)}}>删除</i-button>
        </div>
      );
    },
    align: 'center'

  }
}

// 页码相关
let page = {
  total: 1,
  startIndex: 0,
  stepNumber: 20,
  currentPage: 1
};

//页面状态相关
let status = {
  //新建或编辑员工的弹出框
  modalModify: {
    isShow: false,
    isModify: false,
    isModifyPassword: false,
    title: "",
    isLoading: true,
  },
  //删除员工的 modal
  modalDelete: {
    isShow: false,
    isLoading: true,
    userInfo: {
      id: '',
      userName: ''
    }
  },
  rules: {
    userName: [
      {required: true, message: '姓名不能为空', trigger: 'blur'}
    ],
    password: [
      {required: true, message: '请输入密码', trigger: 'blur'}
    ],
    passwordCheck: [
      {validator: validatePassCheck, trigger: 'blur'}
    ],
    roleId: [
      // {required: true, type: 'string',message: '请选择角色', trigger: 'change'}
    ]
  },

};

// 页面的数据源
let data = {
  userList: [],
  roleList:[]
};

// 和网络交互相关的参数
let params = {
  //新用户或者编辑的用户弹出框的数据
  user: {
    id: '',
    userName: '',
    password: '',
    passwordCheck: '',
    roleId: '',
    roleName: '',
    access: 1,
    roles:[]
  }
};

let role = {
  userAdd:false,
  userEdit:false,
  userDelete:false,
};

export  default  {
  tPage: page,
  tStatus: status,
  tParam: params,
  tData: data

};
